package com.java.controller;


import com.java.entity.vo.FileUploadResult;
import com.java.service.MinioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/minio")
public class MinioController {
    @Autowired
    private MinioService minioService;

    @PostMapping("/upload")
    public FileUploadResult upload(@RequestPart("file") MultipartFile file) {
        // 简单返回下载/外链路径
        if (file.isEmpty()) {
            throw new IllegalArgumentException("文件不可为空");
        }
        return minioService.uploadFile(file);
    }
}
